package com.zhanghp.class030;

/**
 * 找到缺失的数字
 * 测试链接 : https://leetcode.cn/problems/missing-number/
 *
 * @author zhanghp
 * @since 2024/4/3 17:09
 */
public class Code03_MissingNumber {

    static class Solution {
        public int missingNumber(int[] nums) {
            int length = nums.length;
            int eorAll = 0, eorNum = 0;
            for (int i = 0; i < length; i++) {
                eorAll ^= i;
                eorNum ^= nums[i];
            }
            eorAll ^= length;
            return eorAll ^ eorNum;
        }
    }
}
